From the PO.DAAC Cookbook, to access the GitHub version of the notebook, follow this link.
Accessing and Visualizing SWOT Datasets
Requirement:
This tutorial can only be run in an AWS cloud instance running in us-west-2: NASA Earthdata Cloud data in S3 can be directly accessed via earthaccess python library; this access is limited to requests made within the US West (Oregon) (code: us-west-2) AWS region.
Learning Objectives:
Access SWOT HR data prodcuts (archived in NASA Earthdata Cloud) within the AWS cloud, without downloading to local machine
Visualize accessed data for a quick check
SWOT Level 2 KaRIn High Rate Version 1.1 (where available) Datasets:
River Vector Shapefile - SWOT_L2_HR_RIVERSP_1.1
Lake Vector Shapefile - SWOT_L2_HR_LAKESP_1.1
Water Mask Pixel Cloud NetCDF - SWOT_L2_HR_PIXC_1.1
Water Mask Pixel Cloud Vector Attribute NetCDF - SWOT_L2_HR_PIXCVec_1.1
Raster NetCDF - SWOT_L2_HR_Raster_1.1
Single Look Complex Data product - SWOT_L1B_HR_SLC_1.1
Notebook Author: Cassie Nickles, NASA PO.DAAC (Aug 2023) || Other Contributors: Zoe Walschots (PO.DAAC Summer Intern 2023), Catalina Taglialatela (NASA PO.DAAC), Luis Lopez (NASA NSIDC DAAC)
Last updated: 4 Dec 2023
Libraries Needed
import globimport osimport requestsimport s3fsimport fionaimport netCDF4 as ncimport h5netcdfimport xarray as xrimport pandas as pdimport geopandas as gpdimport numpy as npimport matplotlib.pyplot as pltimport hvplot.xarrayimport earthaccessfrom earthaccess import Auth, DataCollections, DataGranules, Store
Earthdata Login
An Earthdata Login account is required to access data, as well as discover restricted data, from the NASA Earthdata system. Thus, to access NASA data, you need Earthdata Login. If you don’t already have one, please visit https://urs.earthdata.nasa.gov to register and manage your Earthdata Login account. This account is free to create and only takes a moment to set up. We use earthaccess to authenticate your login credentials below.
auth = earthaccess.login()
EARTHDATA_USERNAME and EARTHDATA_PASSWORD are not set in the current environment, try setting them or use a different strategy (netrc, interactive)
You're now authenticated with NASA Earthdata Login
Using token with expiration date: 01/07/2024
Using .netrc file for EDL
Single File Access
1. River Vector Shapefiles
The s3 access link can be found using earthaccess data search. Since this collection consists of Reach and Node files, we need to extract only the granule for the Reach file. We do this by filtering for the ‘Reach’ title in the data link.
Alternatively, Earthdata Search (see tutorial) can be used to search in a map graphic user interface.
#Retrieves granule from the day we want, in this case by passing to `earthdata.search_data` function the data collection shortname, temporal bounds, and for restricted data one must specify the search countriver_results = earthaccess.search_data(short_name ='SWOT_L2_HR_RIVERSP_1.1', temporal = ('2023-04-08 00:00:00', '2023-04-22 23:59:59'), granule_name ='*Reach*_013_NA*') # here we filter by Reach files (not node), pass #13 and continent code=NA
Granules found: 14
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
Create Fiona session to work with zip and embedded shapefiles in the AWS Cloud
The native format for this data is a .zip file, and we want the .shp file within the .zip file, so we will create a Fiona AWS session using the credentials from setting up the s3fs session above to access the shapefiles within the zip files. If we don’t do this, the alternative would be to download the data to the cloud environment (e.g. EC2 instance, user S3 bucket) and extract the .zip file there.
# Get the link for the first zip fileriver_link = earthaccess.results.DataGranule.data_links(river_results[0], access='direct')[0]# We use the zip+ prefix so fiona knows that we are operating on a zip fileriver_shp_url =f"zip+{river_link}"with fiona.Env(session=fiona_session): SWOT_HR_shp1 = gpd.read_file(river_shp_url) #view the attribute tableSWOT_HR_shp1
lake_results = earthaccess.search_data(short_name ='SWOT_L2_HR_LAKESP_1.1', temporal = ('2023-04-08 00:00:00', '2023-04-22 23:59:59'), granule_name ='*Obs*_013_NA*') # here we filter by files with 'Obs' in the name (This collection has three options: Obs, Unassigned, and Prior), pass #13 and continent code=NA
Granules found: 14
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
Create Fiona session to work with zip and embedded shapefiles in the AWS Cloud
The native format for this data is a .zip file, and we want the .shp file within the .zip file, so we will create a Fiona AWS session using the credentials from setting up the s3fs session above to access the shapefiles within the zip files. If we don’t do this, the alternative would be to download the data to the cloud environment (e.g. EC2 instance, user S3 bucket) and extract the .zip file there.
# Get the link for the first zip filelake_link = earthaccess.results.DataGranule.data_links(lake_results[0], access='direct')[0]# We use the zip+ prefix so fiona knows that we are operating on a zip filelake_shp_url =f"zip+{lake_link}"with fiona.Env(session=fiona_session): SWOT_HR_shp2 = gpd.read_file(lake_shp_url) #view the attribute tableSWOT_HR_shp2
Accessing the remaining files is different than the shp files above. We do not need to read the shapefiles within a zip file using something like Fiona session (or to download and unzip in the cloud) because the following SWOT HR collections are stored in netCDF files in the cloud. For the rest of the products, we will open via xarray, not geopandas.
pixc_results = earthaccess.search_data(short_name ='SWOT_L2_HR_PIXC_1.1', temporal = ('2023-04-22 00:00:00', '2023-04-22 23:59:59'), granule_name ='*_498_013_*') # here we filter by cycle=498 and pass=013
Granules found: 164
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
fs_s3 = earthaccess.get_s3fs_session(results=pixc_results)# get link for file 100pixc_link = earthaccess.results.DataGranule.data_links(pixc_results[100], access='direct')[0]s3_file_obj3 = fs_s3.open(pixc_link, mode='rb')
Open data using xarray
The pixel cloud netCDF files are formatted with three groups titled, “pixel cloud”, “tvp”, or “noise” (more detail here). In order to access the coordinates and variables within the file, a group must be specified when calling xarray open_dataset.
ds_PIXC = xr.open_dataset(s3_file_obj3, group ='pixel_cloud', engine='h5netcdf')ds_PIXC
Geodetic latitude [-80,80] (degrees north of equator) of the pixel.
[5180594 values with dtype=float64]
longitude
(points)
float64
...
long_name :
longitude (degrees East)
standard_name :
longitude
units :
degrees_east
quality_flag :
geolocation_qual
valid_min :
-180.0
valid_max :
180.0
comment :
Longitude [-180,180) (east of the Greenwich meridian) of the pixel.
[5180594 values with dtype=float64]
azimuth_index
(points)
float64
...
long_name :
rare interferogram azimuth index
units :
1
valid_min :
0
valid_max :
999999
comment :
Rare interferogram azimuth index (indexed from 0).
[5180594 values with dtype=float64]
range_index
(points)
float64
...
long_name :
rare interferogram range index
units :
1
valid_min :
0
valid_max :
999999
comment :
Rare interferogram range index (indexed from 0).
[5180594 values with dtype=float64]
interferogram
(points, complex_depth)
float32
...
long_name :
rare interferogram
units :
1
quality_flag :
interferogram_qual
valid_min :
-1e+20
valid_max :
1e+20
comment :
Complex unflattened rare interferogram.
[10361188 values with dtype=float32]
power_plus_y
(points)
float32
...
long_name :
power for plus_y channel
units :
1
quality_flag :
interferogram_qual
valid_min :
0.0
valid_max :
1e+20
comment :
Power for the plus_y channel (arbitrary units that give sigma0 when noise subtracted and normalized by the X factor).
[5180594 values with dtype=float32]
power_minus_y
(points)
float32
...
long_name :
power for minus_y channel
units :
1
quality_flag :
interferogram_qual
valid_min :
0.0
valid_max :
1e+20
comment :
Power for the minus_y channel (arbitrary units that give sigma0 when noise subtracted and normalized by the X factor).
[5180594 values with dtype=float32]
coherent_power
(points)
float32
...
long_name :
coherent power combination of minus_y and plus_y channels
units :
1
quality_flag :
interferogram_qual
valid_min :
0.0
valid_max :
1e+20
comment :
Power computed by combining the plus_y and minus_y channels coherently by co-aligning the phases (arbitrary units that give sigma0 when noise subtracted and normalized by the X factor).
[5180594 values with dtype=float32]
x_factor_plus_y
(points)
float32
...
long_name :
X factor for plus_y channel power
units :
1
valid_min :
0.0
valid_max :
1e+20
comment :
X factor for the plus_y channel power in linear units (arbitrary units to normalize noise-subtracted power to sigma0).
[5180594 values with dtype=float32]
x_factor_minus_y
(points)
float32
...
long_name :
X factor for minus_y channel power
units :
1
valid_min :
0.0
valid_max :
1e+20
comment :
X factor for the minus_y channel power in linear units (arbitrary units to normalize noise-subtracted power to sigma0).
[5180594 values with dtype=float32]
water_frac
(points)
float32
...
long_name :
water fraction
units :
1
quality_flag :
classification_qual
valid_min :
-1000.0
valid_max :
10000.0
comment :
Noisy estimate of the fraction of the pixel that is water.
[5180594 values with dtype=float32]
water_frac_uncert
(points)
float32
...
long_name :
water fraction uncertainty
units :
1
valid_min :
0.0
valid_max :
999999.0
comment :
Uncertainty estimate of the water fraction estimate (width of noisy water frac estimate distribution).
[5180594 values with dtype=float32]
classification
(points)
float32
...
long_name :
classification
quality_flag :
classification_qual
flag_meanings :
land land_near_water water_near_land open_water dark_water low_coh_water_near_land open_low_coh_water
flag_values :
[1 2 3 4 5 6 7]
valid_min :
1
valid_max :
7
comment :
Flags indicating water detection results.
[5180594 values with dtype=float32]
false_detection_rate
(points)
float32
...
long_name :
false detection rate
units :
1
quality_flag :
classification_qual
valid_min :
0.0
valid_max :
1.0
comment :
Probability of falsely detecting water when there is none.
[5180594 values with dtype=float32]
missed_detection_rate
(points)
float32
...
long_name :
missed detection rate
units :
1
quality_flag :
classification_qual
valid_min :
0.0
valid_max :
1.0
comment :
Probability of falsely detecting no water when there is water.
[5180594 values with dtype=float32]
prior_water_prob
(points)
float32
...
long_name :
prior water probability
units :
1
valid_min :
0.0
valid_max :
1.0
comment :
Prior probability of water occurring.
[5180594 values with dtype=float32]
bright_land_flag
(points)
float32
...
long_name :
bright land flag
standard_name :
status_flag
flag_meanings :
not_bright_land bright_land bright_land_or_water
flag_values :
[0 1 2]
valid_min :
0
valid_max :
2
comment :
Flag indicating areas that are not typically water but are expected to be bright (e.g., urban areas, ice). Flag value 2 indicates cases where prior data indicate land, but where prior_water_prob indicates possible water.
[5180594 values with dtype=float32]
layover_impact
(points)
float32
...
long_name :
layover impact
units :
m
valid_min :
-999999.0
valid_max :
999999.0
comment :
Estimate of the height error caused by layover, which may not be reliable on a pixel by pixel basis, but may be useful to augment aggregated height uncertainties.
[5180594 values with dtype=float32]
eff_num_rare_looks
(points)
float32
...
long_name :
effective number of rare looks
units :
1
valid_min :
0.0
valid_max :
999999.0
comment :
Effective number of independent looks taken to form the rare interferogram.
[5180594 values with dtype=float32]
height
(points)
float32
...
long_name :
height above reference ellipsoid
units :
m
quality_flag :
geolocation_qual
valid_min :
-1500.0
valid_max :
15000.0
comment :
Height of the pixel above the reference ellipsoid.
[5180594 values with dtype=float32]
cross_track
(points)
float32
...
long_name :
approximate cross-track location
units :
m
quality_flag :
geolocation_qual
valid_min :
-75000.0
valid_max :
75000.0
comment :
Approximate cross-track location of the pixel.
[5180594 values with dtype=float32]
pixel_area
(points)
float32
...
long_name :
pixel area
units :
m^2
quality_flag :
geolocation_qual
valid_min :
0.0
valid_max :
999999.0
comment :
Pixel area.
[5180594 values with dtype=float32]
inc
(points)
float32
...
long_name :
incidence angle
units :
degrees
quality_flag :
geolocation_qual
valid_min :
0.0
valid_max :
999999.0
comment :
Incidence angle.
[5180594 values with dtype=float32]
phase_noise_std
(points)
float32
...
long_name :
phase noise standard deviation
units :
radians
valid_min :
-999999.0
valid_max :
999999.0
comment :
Estimate of the phase noise standard deviation.
[5180594 values with dtype=float32]
dlatitude_dphase
(points)
float32
...
long_name :
sensitivity of latitude estimate to interferogram phase
units :
degrees/radian
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the latitude estimate to the interferogram phase.
[5180594 values with dtype=float32]
dlongitude_dphase
(points)
float32
...
long_name :
sensitivity of longitude estimate to interferogram phase
units :
degrees/radian
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the longitude estimate to the interferogram phase.
[5180594 values with dtype=float32]
dheight_dphase
(points)
float32
...
long_name :
sensitivity of height estimate to interferogram phase
units :
m/radian
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the height estimate to the interferogram phase.
[5180594 values with dtype=float32]
dheight_droll
(points)
float32
...
long_name :
sensitivity of height estimate to spacecraft roll
units :
m/degrees
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the height estimate to the spacecraft roll.
[5180594 values with dtype=float32]
dheight_dbaseline
(points)
float32
...
long_name :
sensitivity of height estimate to interferometric baseline
units :
m/m
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the height estimate to the interferometric baseline.
[5180594 values with dtype=float32]
dheight_drange
(points)
float32
...
long_name :
sensitivity of height estimate to range (delay)
units :
m/m
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the height estimate to the range (delay).
[5180594 values with dtype=float32]
darea_dheight
(points)
float32
...
long_name :
sensitivity of pixel area to reference height
units :
m^2/m
quality_flag :
geolocation_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Sensitivity of the pixel area to the reference height.
[5180594 values with dtype=float32]
illumination_time
(points)
datetime64[ns]
...
long_name :
time of illumination of each pixel (UTC)
standard_name :
time
tai_utc_difference :
37.0
leap_second :
0000-00-00T00:00:00Z
comment :
Time of measurement in seconds in the UTC time scale since 1 Jan 2000 00:00:00 UTC. [tai_utc_difference] is the difference between TAI and UTC reference time (seconds) for the first measurement of the data set. If a leap second occurs within the data set, the attribute leap_second is set to the UTC time at which the leap second occurs.
[5180594 values with dtype=datetime64[ns]]
illumination_time_tai
(points)
datetime64[ns]
...
long_name :
time of illumination of each pixel (TAI)
standard_name :
time
comment :
Time of measurement in seconds in the TAI time scale since 1 Jan 2000 00:00:00 TAI. This time scale contains no leap seconds. The difference (in seconds) with time in UTC is given by the attribute [illumination_time:tai_utc_difference].
[5180594 values with dtype=datetime64[ns]]
eff_num_medium_looks
(points)
float32
...
long_name :
effective number of medium looks
units :
1
valid_min :
0.0
valid_max :
999999.0
comment :
Effective number of independent looks taken in forming the medium interferogram (after adaptive averaging).
[5180594 values with dtype=float32]
sig0
(points)
float32
...
long_name :
sigma0
units :
1
quality_flag :
sig0_qual
valid_min :
-999999.0
valid_max :
999999.0
comment :
Normalized radar cross section (sigma0) in real, linear units (not decibels). The value may be negative due to noise subtraction.
[5180594 values with dtype=float32]
sig0_uncert
(points)
float32
...
long_name :
sigma0 uncertainty
units :
1
valid_min :
-999999.0
valid_max :
999999.0
comment :
1-sigma uncertainty in the sig0 measurement. The value is given as an additive (not multiplicative) linear term (not a term in decibels).
[5180594 values with dtype=float32]
phase_unwrapping_region
(points)
float64
...
long_name :
phase unwrapping region index
units :
1
valid_min :
-1
valid_max :
99999999
comment :
Phase unwrapping region index.
[5180594 values with dtype=float64]
ambiguity_cost1
(points)
float32
...
long_name :
phase ambiguity minimum cost
units :
1
valid_min :
-999999.0
valid_max :
999999.0
comment :
Phase ambiguity minimum cost.
[5180594 values with dtype=float32]
ambiguity_cost2
(points)
float32
...
long_name :
phase ambiguity 2nd minimum cost
units :
1
valid_min :
-999999.0
valid_max :
999999.0
comment :
Phase ambiguity 2nd minimum cost.
[5180594 values with dtype=float32]
instrument_range_cor
(points)
float32
...
long_name :
instrument range correction
units :
m
valid_min :
-999999.0
valid_max :
999999.0
comment :
Term that incorporates all calibration corrections applied to range before geolocation.
[5180594 values with dtype=float32]
instrument_phase_cor
(points)
float32
...
long_name :
instrument phase correction
units :
radians
valid_min :
-999999.0
valid_max :
999999.0
comment :
Term that incorporates all calibration corrections applied to phase before geolocation.
[5180594 values with dtype=float32]
instrument_baseline_cor
(points)
float32
...
long_name :
instrument baseline correction
units :
m
valid_min :
-999999.0
valid_max :
999999.0
comment :
Term that incorporates all calibration corrections applied to baseline before geolocation.
[5180594 values with dtype=float32]
sig0_cor_atmos_model
(points)
float32
...
long_name :
two-way atmospheric correction to sigma0 from model
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
units :
1
valid_min :
1.0
valid_max :
10.0
comment :
Atmospheric correction to sigma0 from weather model data as a linear power multiplier (not decibels). sig0_cor_atmos_model is already applied in computing sig0 and x_factor_plus_y and x_factor_minus_y.
[5180594 values with dtype=float32]
height_cor_xover
(points)
float32
...
long_name :
height correction from KaRIn crossovers
units :
m
valid_min :
-10.0
valid_max :
10.0
comment :
Height correction from KaRIn crossover calibration. The correction is applied before geolocation but reported as an equivalent height correction.
[5180594 values with dtype=float32]
model_dry_tropo_cor
(points)
float32
...
long_name :
dry troposphere vertical correction
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
units :
m
valid_min :
-3.0
valid_max :
-1.5
comment :
Equivalent vertical correction due to dry troposphere delay. The reported pixel height, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported pixel height results in the uncorrected pixel height.
[5180594 values with dtype=float32]
model_wet_tropo_cor
(points)
float32
...
long_name :
wet troposphere vertical correction
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
units :
m
valid_min :
-1.0
valid_max :
0.0
comment :
Equivalent vertical correction due to wet troposphere delay. The reported pixel height, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported pixel height results in the uncorrected pixel height.
[5180594 values with dtype=float32]
iono_cor_gim_ka
(points)
float32
...
long_name :
ionosphere vertical correction
source :
Global Ionosphere Maps
institution :
JPL
units :
m
valid_min :
-0.5
valid_max :
0.0
comment :
Equivalent vertical correction due to ionosphere delay. The reported pixel height, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported pixel height results in the uncorrected pixel height.
[5180594 values with dtype=float32]
geoid
(points)
float32
...
long_name :
geoid height
standard_name :
geoid_height_above_reference_ellipsoid
source :
EGM2008 (Pavlis et al., 2012)
units :
m
valid_min :
-150.0
valid_max :
150.0
comment :
Geoid height above the reference ellipsoid with a correction to refer the value to the mean tide system, i.e. includes the permanent tide (zero frequency). This value is reported for reference but is not applied to the reported height.
[5180594 values with dtype=float32]
solid_earth_tide
(points)
float32
...
long_name :
solid Earth tide height
source :
Cartwright and Taylor (1971) and Cartwright and Edden (1973)
units :
m
valid_min :
-1.0
valid_max :
1.0
comment :
Solid-Earth (body) tide height. The zero-frequency permanent tide component is not included. This value is reported for reference but is not applied to the reported height.
[5180594 values with dtype=float32]
load_tide_fes
(points)
float32
...
long_name :
geocentric load tide height (FES)
source :
FES2014b (Carrere et al., 2016)
institution :
LEGOS/CNES
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric load tide height. The effect of the ocean tide loading of the Earth's crust. This value is reported for reference but is not applied to the reported height.
[5180594 values with dtype=float32]
load_tide_got
(points)
float32
...
long_name :
geocentric load tide height (GOT)
source :
GOT4.10c (Ray, 2013)
institution :
GSFC
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric load tide height. The effect of the ocean tide loading of the Earth's crust. This value is reported for reference but is not applied to the reported height.
[5180594 values with dtype=float32]
pole_tide
(points)
float32
...
long_name :
geocentric pole tide height
source :
Wahr (1985) and Desai et al. (2015)
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric pole tide height. The total of the contribution from the solid-Earth (body) pole tide height and the load pole tide height (i.e., the effect of the ocean pole tide loading of the Earth's crust). This value is reported for reference but is not applied to the reported height.
[5180594 values with dtype=float32]
ancillary_surface_classification_flag
(points)
float32
...
long_name :
surface classification
standard_name :
status_flag
source :
MODIS/GlobCover
institution :
European Space Agency
flag_meanings :
open_ocean land continental_water aquatic_vegetation continental_ice_snow floating_ice salted_basin
flag_values :
[0 1 2 3 4 5 6]
valid_min :
0
valid_max :
6
comment :
7-state surface type classification computed from a mask built with MODIS and GlobCover data.
Quality flag for pixel cloud data per rare-posted interferogram line (similar to slc_qual in the L1B_HR_SLC product)
[3239 values with dtype=float64]
pixc_line_to_tvp
(num_pixc_lines)
float32
...
long_name :
pixel cloud rare line to tvp index
units :
1
valid_min :
0.0
valid_max :
999999.0
comment :
Pixel cloud rare radar grid line index to tvp index mapping
[3239 values with dtype=float32]
description :
cloud of geolocated interferogram pixels
interferogram_size_azimuth :
3239
interferogram_size_range :
5526
looks_to_efflooks :
1.5309342049156023
num_azimuth_looks :
7.0
azimuth_offset :
3
Simple plot of the results
# This could take a few minutes to plotplt.scatter(x=ds_PIXC.longitude, y=ds_PIXC.latitude, c=ds_PIXC.height)plt.colorbar().set_label('Height (m)')
4. Water Mask Pixel Cloud Vector Attribute NetCDF
Search for data of interest
pixcvec_results = earthaccess.search_data(short_name ='SWOT_L2_HR_PIXCVEC_1.1', temporal = ('2023-04-08 00:00:00', '2023-04-22 23:59:59'), granule_name ='*_498_013_*') # here we filter by cycle=498 and pass=013
Granules found: 100
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
fs_s3 = earthaccess.get_s3fs_session(results=pixcvec_results)# get link for file 0pixcvec_link = earthaccess.results.DataGranule.data_links(pixcvec_results[0], access='direct')[0]s3_file_obj4 = fs_s3.open(pixcvec_link, mode='rb')
Rare interferogram azimuth index (indexed from 0).
[11174047 values with dtype=int32]
range_index
(points)
int32
...
_FillValue :
2147483647
long_name :
rare interferogram range index
units :
1
valid_min :
0
valid_max :
999999
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Rare interferogram range index (indexed from 0).
[11174047 values with dtype=int32]
latitude_vectorproc
(points)
float64
...
_FillValue :
9.969209968386869e+36
long_name :
height-constrained geolocation latitude
standard_name :
latitude
units :
degrees_north
valid_min :
-80.0
valid_max :
80.0
comment :
Height-constrained geodetic latitude of the pixel. Units are in degrees north of the equator.
[11174047 values with dtype=float64]
longitude_vectorproc
(points)
float64
...
_FillValue :
9.969209968386869e+36
long_name :
height-constrained geolocation longitude
standard_name :
longitude
units :
degrees_east
valid_min :
-180.0
valid_max :
180.0
comment :
Height-constrained geodetic longitude of the pixel. Positive=degrees east of the Greenwich meridian. Negative=degrees west of the Greenwich meridian.
[11174047 values with dtype=float64]
height_vectorproc
(points)
float32
...
_FillValue :
9.96921e+36
long_name :
height above reference ellipsoid
units :
m
valid_min :
-1500.0
valid_max :
15000.0
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Height-constrained height of the pixel above the reference ellipsoid.
[11174047 values with dtype=float32]
reach_id
(points, nchar_reach_id)
|S1
...
long_name :
identifier of the associated prior river reach
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Unique reach identifier from the prior river database. The format of the identifier is CBBBBBRRRRT, where C=continent, B=basin, R=reach, T=type.
[122914517 values with dtype=|S1]
node_id
(points, nchar_node_id)
|S1
...
long_name :
identifier of the associated prior river node
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Unique node identifier from the prior river database. The format of the identifier is CBBBBBRRRRNNNT, where C=continent, B=basin, R=reach, N=node, T=type of water body.
[156436658 values with dtype=|S1]
lake_id
(points, nchar_lake_id)
|S1
...
long_name :
identifier of the associated prior lake
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Identifier of the lake from the lake prior database) associated to the pixel. The format of the identifier is CBBNNNNNNT, where C=continent, B=basin, N=counter within the basin, T=type of water body.
[111740470 values with dtype=|S1]
obs_id
(points, nchar_obs_id)
|S1
...
long_name :
identifier of the observed feature
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Tile-specific identifier of the observed feature associated to the pixel. The format of the identifier is CBBTTTSNNNNNN, where C=continent, B=basin, T=tile number, S=swath side, N=lake counter within the PIXC tile.
[145262611 values with dtype=|S1]
ice_clim_f
(points)
int8
...
_FillValue :
127
long_name :
climatological ice cover flag
flag_meanings :
no_ice_cover uncertain_ice_cover full_ice_cover
flag_values :
[0 1 2]
institution :
University of North Carolina
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Climatological ice cover flag indicating whether the pixel is ice-covered on the day of the observation based on external climatological information (not the SWOT measurement). Values of 0, 1, and 2 indicate that the surface is not ice covered, may or may not be partially or fully ice covered, and fully ice covered, respectively. A value of 127 indicates that this flag is not available.
[11174047 values with dtype=int8]
ice_dyn_f
(points)
int8
...
_FillValue :
127
long_name :
dynamical ice cover flag
flag_meanings :
no_ice_cover partial_ice_cover full_ice_cover
flag_values :
[0 1 2]
institution :
University of North Carolina
coordinates :
longitude_vectorproc latitude_vectorproc
comment :
Dynamic ice cover flag indicating whether the pixel is ice-covered on the day of the observation based on analysis of external satellite optical data. Values of 0, 1, and 2 indicate that the surface is not ice covered, partially ice covered, and fully ice covered, respectively. A value of 255 indicates that this flag is not available.
[11174047 values with dtype=int8]
Conventions :
CF-1.7
title :
Level 2 KaRIn high rate pixel cloud vector attribute product
short_name :
L2_HR_PIXCVec
institution :
JPL
source :
Level 1B KaRIn High Rate Single Look Complex Data Product
history :
2023-09-07T04:43:11.652934Z: Creation
platform :
SWOT
references :
SWOT-DD-CDM-0565-CNES_SAS_Design_L2_HR_LakeSP - Revision A - 20220531
reference_document :
SWOT-TN-CDM-0677-CNES_Product_Description_L2_HR_PIXCVec - Revision A - 20220531
pixcvec_htvals = ds_PIXCVEC.height_vectorproc.compute()pixcvec_latvals = ds_PIXCVEC.latitude_vectorproc.compute()pixcvec_lonvals = ds_PIXCVEC.longitude_vectorproc.compute()#Before plotting, we set all fill values to nan so that the graph shows up better spatiallypixcvec_htvals[pixcvec_htvals >15000] = np.nanpixcvec_latvals[pixcvec_latvals >80] = np.nanpixcvec_latvals[pixcvec_latvals <-80] = np.nanpixcvec_lonvals[pixcvec_lonvals >180] = np.nanpixcvec_lonvals[pixcvec_lonvals <-180] = np.nan
#Say we know the exact cycle, pass & scene. We can search for one data granule!raster_results = earthaccess.search_data(short_name ='SWOT_L2_HR_Raster_1.1', temporal = ('2023-04-01 00:00:00', '2023-04-22 23:59:59'), granule_name ='*100m*_498_013_130F*') # here we filter by files with '100m' in the name (This collection has two resolution options: 100m & 250m), cycle=498, pass=013, scene = 130F
Granules found: 1
Set up an s3fs session for Direct Cloud Access
s3fs sessions are used for authenticated access to s3 bucket and allows for typical file-system style operations. Below we create session by passing in the data access information.
fs_s3 = earthaccess.get_s3fs_session(results=raster_results)# get link for file raster_link = earthaccess.results.DataGranule.data_links(raster_results[0], access='direct')[0]s3_file_obj5 = fs_s3.open(raster_link, mode='rb')
PROJCS["WGS 84 / UTM zone 11N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32611"]]
spatial_ref :
PROJCS["WGS 84 / UTM zone 11N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-117],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Easting",EAST],AXIS["Northing",NORTH],AUTHORITY["EPSG","32611"]]
comment :
UTM zone coordinate reference system.
[1 values with dtype=object]
longitude
(y, x)
float64
...
long_name :
longitude (degrees East)
standard_name :
longitude
grid_mapping :
crs
units :
degrees_east
valid_min :
-180.0
valid_max :
180.0
comment :
Geodetic longitude [-180,180) (east of the Greenwich meridian) of the pixel.
[2727452 values with dtype=float64]
latitude
(y, x)
float64
...
long_name :
latitude (positive N, negative S)
standard_name :
latitude
grid_mapping :
crs
units :
degrees_north
valid_min :
-80.0
valid_max :
80.0
comment :
Geodetic latitude [-80,80] (degrees north of equator) of the pixel.
[2727452 values with dtype=float64]
wse
(y, x)
float32
...
long_name :
water surface elevation above geoid
grid_mapping :
crs
units :
m
quality_flag :
wse_qual
valid_min :
-1500.0
valid_max :
15000.0
comment :
Water surface elevation of the pixel above the geoid and after using models to subtract the effects of tides (solid_earth_tide, load_tide_fes, pole_tide).
[2727452 values with dtype=float32]
wse_qual
(y, x)
float32
...
long_name :
summary quality indicator for the water surface elevation
standard_name :
status_flag
grid_mapping :
crs
flag_meanings :
good suspect degraded bad
flag_values :
[0 1 2 3]
valid_min :
0
valid_max :
3
comment :
Summary quality indicator for the water surface elevation quantities. A value of 0 indicates a nominal measurement, 1 indicates a suspect measurement, 2 indicates a degraded measurement, and 3 indicates a bad measurement.
[2727452 values with dtype=float32]
wse_qual_bitwise
(y, x)
float64
...
long_name :
bitwise quality indicator for the water surface elevation
Bitwise quality indicator for the water surface elevation quantities. If this word is interpreted as an unsigned integer, a value of 0 indicates good data, positive values less than 32768 represent suspect data, values greater than or equal to 32768 but less than 8388608 represent degraded data, and values greater than or equal to 8388608 represent bad data.
[2727452 values with dtype=float64]
wse_uncert
(y, x)
float32
...
long_name :
uncertainty in the water surface elevation
grid_mapping :
crs
units :
m
valid_min :
0.0
valid_max :
999999.0
comment :
1-sigma uncertainty in the water surface elevation.
[2727452 values with dtype=float32]
water_area
(y, x)
float32
...
long_name :
water surface area
grid_mapping :
crs
units :
m^2
quality_flag :
water_area_qual
valid_min :
-2000000.0
valid_max :
2000000000.0
comment :
Surface area of the water pixels.
[2727452 values with dtype=float32]
water_area_qual
(y, x)
float32
...
long_name :
summary quality indicator for the water surface area
standard_name :
status_flag
grid_mapping :
crs
flag_meanings :
good suspect degraded bad
flag_values :
[0 1 2 3]
valid_min :
0
valid_max :
3
comment :
Summary quality indicator for the water surface area and water fraction quantities. A value of 0 indicates a nominal measurement, 1 indicates a suspect measurement, 2 indicates a degraded measurement, and 3 indicates a bad measurement.
[2727452 values with dtype=float32]
water_area_qual_bitwise
(y, x)
float64
...
long_name :
bitwise quality indicator for the water surface area
Bitwise quality indicator for the water surface area and water fraction quantities. If this word is interpreted as an unsigned integer, a value of 0 indicates good data, positive values less than 32768 represent suspect data, values greater than or equal to 32768 but less than 8388608 represent degraded data, and values greater than or equal to 8388608 represent bad data.
[2727452 values with dtype=float64]
water_area_uncert
(y, x)
float32
...
long_name :
uncertainty in the water surface area
grid_mapping :
crs
units :
m^2
valid_min :
0.0
valid_max :
2000000000.0
comment :
1-sigma uncertainty in the water surface area.
[2727452 values with dtype=float32]
water_frac
(y, x)
float32
...
long_name :
water fraction
grid_mapping :
crs
units :
1
quality_flag :
water_area_qual
valid_min :
-1000.0
valid_max :
10000.0
comment :
Fraction of the pixel that is water.
[2727452 values with dtype=float32]
water_frac_uncert
(y, x)
float32
...
long_name :
uncertainty in the water fraction
grid_mapping :
crs
units :
1
valid_min :
0.0
valid_max :
999999.0
comment :
1-sigma uncertainty in the water fraction.
[2727452 values with dtype=float32]
sig0
(y, x)
float32
...
long_name :
sigma0
grid_mapping :
crs
units :
1
quality_flag :
sig0_qual
valid_min :
-1000.0
valid_max :
10000000.0
comment :
Normalized radar cross section (sigma0) in real, linear units (not decibels). The value may be negative due to noise subtraction.
[2727452 values with dtype=float32]
sig0_qual
(y, x)
float32
...
long_name :
summary quality indicator for the sigma0
standard_name :
status_flag
grid_mapping :
crs
flag_meanings :
good suspect degraded bad
flag_values :
[0 1 2 3]
valid_min :
0
valid_max :
3
comment :
Summary quality indicator for the sigma0 quantities. A value of 0 indicates a nominal measurement, 1 indicates a suspect measurement, 2 indicates a degraded measurement, and 3 indicates a bad measurement.
Bitwise quality indicator for the sigma0 quantities. If this word is interpreted as an unsigned integer, a value of 0 indicates good data, positive values less than 32768 represent suspect data, values greater than or equal to 32768 but less than 8388608 represent degraded data, and values greater than or equal to 8388608 represent bad data.
[2727452 values with dtype=float64]
sig0_uncert
(y, x)
float32
...
long_name :
uncertainty in sigma0
grid_mapping :
crs
units :
1
valid_min :
0.0
valid_max :
1000.0
comment :
1-sigma uncertainty in sigma0. The value is provided in linear units. This value is a one-sigma additive (not multiplicative) uncertainty term, which can be added to or subtracted from sigma0.
[2727452 values with dtype=float32]
inc
(y, x)
float32
...
long_name :
incidence angle
grid_mapping :
crs
units :
degrees
valid_min :
0.0
valid_max :
90.0
comment :
Incidence angle.
[2727452 values with dtype=float32]
cross_track
(y, x)
float32
...
long_name :
approximate cross-track location
grid_mapping :
crs
units :
m
valid_min :
-75000.0
valid_max :
75000.0
comment :
Approximate cross-track location of the pixel.
[2727452 values with dtype=float32]
illumination_time
(y, x)
datetime64[ns]
...
long_name :
time of illumination of each pixel (UTC)
standard_name :
time
tai_utc_difference :
37.0
leap_second :
0000-00-00T00:00:00Z
comment :
Time of measurement in seconds in the UTC time scale since 1 Jan 2000 00:00:00 UTC. [tai_utc_difference] is the difference between TAI and UTC reference time (seconds) for the first measurement of the data set. If a leap second occurs within the data set, the attribute leap_second is set to the UTC time at which the leap second occurs.
[2727452 values with dtype=datetime64[ns]]
illumination_time_tai
(y, x)
datetime64[ns]
...
long_name :
time of illumination of each pixel (TAI)
standard_name :
time
comment :
Time of measurement in seconds in the TAI time scale since 1 Jan 2000 00:00:00 TAI. This time scale contains no leap seconds. The difference (in seconds) with time in UTC is given by the attribute [illumination_time:tai_utc_difference].
[2727452 values with dtype=datetime64[ns]]
n_wse_pix
(y, x)
float64
...
long_name :
number of water surface elevation pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in water surface elevation aggregation.
[2727452 values with dtype=float64]
n_water_area_pix
(y, x)
float64
...
long_name :
number of water surface area pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in water surface area and water fraction aggregation.
[2727452 values with dtype=float64]
n_sig0_pix
(y, x)
float64
...
long_name :
number of sigma0 pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in sigma0 aggregation.
[2727452 values with dtype=float64]
n_other_pix
(y, x)
float64
...
long_name :
number of other pixels
grid_mapping :
crs
units :
l
valid_min :
0
valid_max :
999999
comment :
Number of pixel cloud samples used in aggregation of quantities not related to water surface elevation, water surface area, water fraction or sigma0.
[2727452 values with dtype=float64]
dark_frac
(y, x)
float32
...
long_name :
fractional area of dark water
grid_mapping :
crs
units :
l
valid_min :
-1000.0
valid_max :
10000.0
comment :
Fraction of pixel water surface area covered by dark water.
[2727452 values with dtype=float32]
ice_clim_flag
(y, x)
float32
...
long_name :
climatological ice cover flag
standard_name :
status_flag
source :
UNC
grid_mapping :
crs
flag_meanings :
no_ice_cover uncertain_ice_cover full_ice_cover
flag_values :
[0 1 2]
valid_min :
0
valid_max :
2
comment :
Climatological ice cover flag indicating whether the pixel is ice-covered on the day of the observation based on external climatological information (not the SWOT measurement). Values of 0, 1, and 2 indicate that the pixel is likely not ice covered, may or may not be partially or fully ice covered, and likely fully ice covered, respectively.
[2727452 values with dtype=float32]
ice_dyn_flag
(y, x)
float32
...
long_name :
dynamic ice cover flag
standard_name :
status_flag
source :
UNC
grid_mapping :
crs
flag_meanings :
no_ice_cover partial_ice_cover full_ice_cover
flag_values :
[0 1 2]
valid_min :
0
valid_max :
2
comment :
Dynamic ice cover flag indicating whether the surface is ice-covered on the day of the observation based on analysis of external satellite optical data. Values of 0, 1, and 2 indicate that the pixel is not ice covered, partially ice covered, and fully ice covered, respectively.
[2727452 values with dtype=float32]
layover_impact
(y, x)
float32
...
long_name :
layover impact
grid_mapping :
crs
units :
m
valid_min :
-999999.0
valid_max :
999999.0
comment :
Estimate of the water surface elevation error caused by layover.
[2727452 values with dtype=float32]
sig0_cor_atmos_model
(y, x)
float32
...
long_name :
two-way atmospheric correction to sigma0 from model
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
grid_mapping :
crs
units :
1
valid_min :
1.0
valid_max :
10.0
comment :
Atmospheric correction to sigma0 from weather model data as a linear power multiplier (not decibels). sig0_cor_atmos_model is already applied in computing sig0.
[2727452 values with dtype=float32]
height_cor_xover
(y, x)
float32
...
long_name :
height correction from KaRIn crossovers
grid_mapping :
crs
units :
m
valid_min :
-10.0
valid_max :
10.0
comment :
Height correction from KaRIn crossover calibration. The correction is applied before geolocation but reported as an equivalent height correction.
[2727452 values with dtype=float32]
geoid
(y, x)
float32
...
long_name :
geoid height
standard_name :
geoid_height_above_reference_ellipsoid
source :
EGM2008 (Pavlis et al., 2012)
grid_mapping :
crs
units :
m
valid_min :
-150.0
valid_max :
150.0
comment :
Geoid height above the reference ellipsoid with a correction to refer the value to the mean tide system, i.e. includes the permanent tide (zero frequency).
[2727452 values with dtype=float32]
solid_earth_tide
(y, x)
float32
...
long_name :
solid Earth tide height
source :
Cartwright and Taylor (1971) and Cartwright and Edden (1973)
grid_mapping :
crs
units :
m
valid_min :
-1.0
valid_max :
1.0
comment :
Solid-Earth (body) tide height. The zero-frequency permanent tide component is not included.
[2727452 values with dtype=float32]
load_tide_fes
(y, x)
float32
...
long_name :
geocentric load tide height (FES)
source :
FES2014b (Carrere et al., 2016)
institution :
LEGOS/CNES
grid_mapping :
crs
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric load tide height. The effect of the ocean tide loading of the Earth’s crust.
[2727452 values with dtype=float32]
load_tide_got
(y, x)
float32
...
long_name :
geocentric load tide height (GOT)
source :
GOT4.10c (Ray, 2013)
institution :
GSFC
grid_mapping :
crs
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric load tide height. The effect of the ocean tide loading of the Earth’s crust. This value is reported for reference but is not applied to the reported height.
[2727452 values with dtype=float32]
pole_tide
(y, x)
float32
...
long_name :
geocentric pole tide height
source :
Wahr (1985) and Desai et al. (2015)
grid_mapping :
crs
units :
m
valid_min :
-0.2
valid_max :
0.2
comment :
Geocentric pole tide height. The total of the contribution from the solid-Earth (body) pole tide height and the load pole tide height (i.e., the effect of the ocean pole tide loading of the Earth’s crust).
[2727452 values with dtype=float32]
model_dry_tropo_cor
(y, x)
float32
...
long_name :
dry troposphere vertical correction
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
grid_mapping :
crs
units :
m
valid_min :
-3.0
valid_max :
-1.5
comment :
Equivalent vertical correction due to dry troposphere delay. The reported water surface elevation, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported water surface elevation results in the uncorrected pixel height.
[2727452 values with dtype=float32]
model_wet_tropo_cor
(y, x)
float32
...
long_name :
wet troposphere vertical correction
source :
European Centre for Medium-Range Weather Forecasts
institution :
ECMWF
grid_mapping :
crs
units :
m
valid_min :
-1.0
valid_max :
0.0
comment :
Equivalent vertical correction due to wet troposphere delay. The reported water surface elevation, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported water surface elevation results in the uncorrected pixel height.
[2727452 values with dtype=float32]
iono_cor_gim_ka
(y, x)
float32
...
long_name :
ionosphere vertical correction
source :
Global Ionosphere Maps
institution :
JPL
grid_mapping :
crs
units :
m
valid_min :
-0.5
valid_max :
0.0
comment :
Equivalent vertical correction due to ionosphere delay. The reported water surface elevation, latitude and longitude are computed after adding negative media corrections to uncorrected range along slant-range paths, accounting for the differential delay between the two KaRIn antennas. The equivalent vertical correction is computed by applying obliquity factors to the slant-path correction. Adding the reported correction to the reported water surface elevation results in the uncorrected pixel height.